package loan.calc.dto;

import loan.calc.domain.LoanRepaySegmentDO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import loan.calc.constant.dict.FinalPeriodMergeTypeEnum;
import loan.calc.constant.dict.InstalmentResetFlagEnum;
import loan.calc.constant.dict.RepayFrequencyTypeEnum;
import loan.calc.constant.dict.RepayMethodDictEnum;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
public class LoanRepaySegmentDTO extends LoanRepaySegmentDO implements Serializable {

    private List<LoanRepaymentScheduleDTO> loanRepaymentScheduleList;

    public void setSegmentId(Long segmentId) {
        super.setSegmentId(segmentId);
        if (loanRepaymentScheduleList != null) {
            loanRepaymentScheduleList.forEach(i -> i.setRepaySegmentId(segmentId));
        }
    }

    public void setLoanId(Long loanId) {
        super.setLoanId(loanId);
        if (loanRepaymentScheduleList != null) {
            loanRepaymentScheduleList.forEach(i -> i.setLoanId(loanId));
        }
    }
}
